<?php
ob_start();
echo $this->renderPartial('_shoping_cart_email_template', array('orderId' => $orderId, 'totalCost' => $totalCost, 'transaction_id' => $transaction_id, 'order_date_time' => $order_date_time));
$mailmodel = EmailTemplate::model()->findByPk(Message::AFTER_PURCHAGE_ORDER);
$content = ob_get_clean();
$mailbody = array('value' => $mailmodel->body, 'type' => 'html');
$userName = Users::model()->findByPk(getLoginUserId());
$userName = $userName->username;
$arrayFind = array('[username]', '[order_details]');
$arrayReplace = array($userName, $content);
$mailbody = str_replace($arrayFind, $arrayReplace, $mailbody);
$mailtemp = Template::model()->findByPk($mailmodel->template_id);
$subject = $mailmodel->subject;
$body = $this->renderPartial('/mails/' . $mailtemp->filename, array('mailbody' => $mailbody['value']), true, false);

try {
    SkillSendMail::SendMailCreateCLassCourse($userName, $subject, $body);
    ShoppingCartByUser::model()->deleteAll('user_id=' . getLoginUserId());
    Yii::app()->shoppingCart->clear();
    Coupons::unsetSessionShopingcart();
} catch (Exception $e) {
    echo $e;
    exit;
}
?>
<?php $classCourse = PurchaseClassCourse::model()->findAll('purchaseorder_id=' . $orderId) ?>
<?php
$classWorkShop = '';
foreach ($classCourse as $classCourse) {
    if (!empty($classCourse->classes_id)) {
        $classWorkShop.= getClassName($classCourse->classes_id) . ', ';
    }
}
?>

<section id="thankyou">
    <div class="container">
        <div class="row">   
            <div class="col-lg-12">         
                <div id="Bread">
                    <ol class="breadcrumb">
                        <li><a href="<?php echo SITE_URL; ?>">Home</a></li>
                        <li class="active">Thank You</li>
                    </ol>
                </div><!--bread-->
            </div>
        </div>

        <div class="gap"></div>
        <div class="row" style="min-height: 250px;">      
            <div class="row">
                <div class="col-lg-8">
                    <h1>Thank you for buying seats to <?php echo substr($classWorkShop, 0, -2); ?>! A confirmation mail with full details has been mailed to the registered id.</h1>
                    <div class="gap"></div>
                    <p></p>
                </div>
                <div class="col-lg-4"></div>
            </div>           

            <div class="gap"></div>
            <div class="gap"></div>
            <div class="gap1"></div>
        </div><!-- Main Container Class -->

</section>



<script>
    function delayedRedirect() {
        window.location = "<?php echo Yii::app()->createUrl("/myskillhippo/"); ?>"
    }
    $(document).ready(function() {
        setTimeout('delayedRedirect()', 3000)

    });
</script>
